function switchTab(identify,index,count) {
	for(i=0;i<count;i++) {
		var CurTabObj = document.getElementById("Tab_"+identify+"_"+i) ;
		var CurListObj = document.getElementById("List_"+identify+"_"+i) ;
		if (i != index) {
			fRemoveClass(CurTabObj , "upH2") ;
			fRemoveClass(CurListObj , "upBox") ;
		}
	}
	try {
		for (ind=0;ind<CachePic['recommend'][index].length ;ind++ ) {
			var picobj = document.getElementById("recommend_pic_"+index+"_"+ind) ;
			//if (picobj.src == "http://images.movie.xunlei.com/img_default.gif") {
				picobj.src = CachePic['recommend'][index][ind] ;
			//}
		}
	}
	catch (e) {}
	
	fAddClass(document.getElementById("Tab_"+identify+"_"+index),"upH2") ;
	fAddClass(document.getElementById("List_"+identify+"_"+index),"upBox") ;
}

function fAddClass(XEle, XClass) {
  if(!XClass) throw new Error("XClass 不能为空!");
  if(XEle.className!="") {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = XEle.className.replace(Re, "");
	var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
	if (OldClassName == "" ) {
		 XEle.className = XClass;
	}
	else {
		XEle.className = OldClassName + " " + XClass;
	}
  }
  else XEle.className = XClass;
}

function fRemoveClass(XEle, XClass) {
  if(!XClass) throw new Error("XClass 不能为空!");
  var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
  if(OldClassName!="") {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = OldClassName.replace(Re, "");
  }
}
var pre_searchtype = "search" ;
function changeSearchType(type) {
	if ($("searchType_"+pre_searchtype)) {
		$("searchType_"+pre_searchtype).className = "" ;
	}
	pre_searchtype = type ;
	$("searchType_"+type).className = "currA" ;
	setResType(type) ;
	if ($("searchbox1").value == '搜索超过10万部影视内容') {
		$("searchbox1").value = "" ;
	}
	else {
		$("searchbox1").value = $("searchbox1").value + "" ;
	}
	$("searchbox1").focus() ;
}
function $(item){
	return document.getElementById(item);
}
//document.domain='xunlei.com';
function c_getCookie(sName){
	var sSearch = sName + "=";
	var iOffset = document.cookie.indexOf(sSearch);
	if (iOffset != -1) {
		iOffset += sSearch.length;
		var iEnd = document.cookie.indexOf(";", iOffset);
		if (iEnd == -1)
			iEnd = document.cookie.length;
		return unescape(document.cookie.substring(iOffset, iEnd));
	}else 
		return "";
}
function c_setCookie(sName,sValue,sHours){
	if(arguments.length>2){
		var expireDate=new Date(new Date().getTime()+sHours*3600000);
		document.cookie = sName + "=" + escape(sValue) + "; path=/; domain=xunlei.com; expires=" + expireDate.toGMTString();
	}else
		document.cookie = sName + "=" + escape(sValue) + "; path=/; domain=xunlei.com"; 
}
function c_login(u){
	top.location='http://i.xunlei.com/account/login.html?url='+encodeURIComponent(u);
}
function c_logout(o){
	c_setCookie("sessionid","");
	o.innerHTML='<a href="javascript:c_login(top.location);"> 登录 </a><a href="javascript:c_regist(top.location);"> 注册 </a>';
}
function c_regist(u){
	top.location='http://i.xunlei.com/account/signup2.shtml?url='+encodeURIComponent(u);
}
function c_verfySession(o){
	if(c_getCookie('sessionid')!=''){
		o.innerHTML='<a href="javascript:;">'+c_getCookie('nickname')+'('+c_getCookie('usrname')+')</a><a  href="javascript:c_logout('+o.id+');" >退出  </a>';
	}
}
//页面登录信息初始化
function initLogininfo()
{
	 var headDiv = $("div_userinfo");
	 if(headDiv){
		c_verfySession(headDiv);
	 }
}
function doLoginOut(){
	 var headDiv = $("div_userinfo");
	 if(headDiv){
		c_logout(headDiv);
	 }
}
//向左滚动
ScrollCrossLeft={interval:0,count:0,duration:0,step:0,srcObj:null,callback:null};
ScrollCrossLeft.doit=function(obj,b,c,d){
	var s=ScrollCrossLeft;
	obj.style.marginLeft=cpu(s.count,b,c,d)+'px';
	s.count++;
	if(s.count==d){
		clearInterval(s.interval);
		s.count=0;
		obj.style.marginLeft=b+c+'px';
		s.callback();
	}
	function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}
ScrollCrossLeft.scroll=function(obj,step,span,beign,callback,duration){
	var s=ScrollCrossLeft;
	s.duration=duration;
	s.callback=callback;
	s.interval=setInterval(function(){s.doit(obj,beign,step*span,duration)},10);
}
//首页
var HotPlay={current:0,step:468,a:'a_hp_',div:'div_hp_content',ul:'ul_hp',clickflag:0}
var Movie_red={current:0,step:230,a:'a_m_red_',div:'div_m_red_content',ul:'ul_m_red',clickflag:0}
var Movie_new={current:0,step:230,a:'a_m_new_',div:'div_m_new_content',ul:'ul_m_new',clickflag:0}
var TV_red={current:0,step:230,a:'a_tv_red_',div:'div_tv_red_content',ul:'ul_tv_red',clickflag:0}
var TV_new={current:0,step:230,a:'a_tv_new_',div:'div_tv_new_content',ul:'ul_tv_new',clickflag:0}
//综艺首页
var Brand_column={current:0,step:0,a:'a_brand_column_',div:'div_brand_column_content',ul:'ul_brand_column'}

var Turn={}
Turn.pre=function(obj){
	if(obj.current==0){
		return;
	}else{
		Turn.go(obj,obj.current-1);
	}
}
Turn.next=function(obj){
	if(obj.current==2){
		return;
	}else{
		Turn.go(obj,obj.current+1);
	}
}
Turn.go=function(obj,index){
	if(obj.current==index){return;}
	var span=-index+obj.current;
	if(obj.clickflag > 0){return;}
	obj.clickflag=1;
	if(obj.step>0) {
		try {
			//showImage(index) ;
			if (obj.img) {
				setTimeout( function () {
							for (cnt=index*6;cnt<=((index+1)*6 -1 );cnt++ ) {
								var picobj = document.getElementById(obj.div　+ "_pic_" + cnt) ;
								//alert(obj.img[cnt]) ;
								//if (picobj.src == "http://images.movie.xunlei.com/img_default.gif"){
									picobj.src = obj.img[cnt] ;
								//}
							}
						}, 50) ;
			}
		}
		catch (e){}
		ScrollCrossLeft.scroll($(obj.div),obj.step,span,parseInt($(obj.div).style.marginLeft)||0,cb,10);
	}
	else{
		displayNOrY();
		cb();	
	}
	function showImage() {
		for (cnt=index*6;cnt<=((index+1)*6 -1 );cnt++ ) {
			var picobj = document.getElementById(obj.div　+ "_pic_" + cnt) ;
			//alert(obj.img[cnt]) ;
			if (picobj.src == "http://images.movie.xunlei.com/img_default.gif"){
				picobj.src = obj.img[cnt] ;
			}
		}
	}
	function imgSrc(index,id){
		var arr_img=$(id+'_'+index).getElementsByTagName('img');
		for(var i=0;i<6;i++){
			arr_img[i].src=obj.imgs[index-1][i];
		}
	}
	function cb(){
		obj.current=index;
		obj.clickflag=0;
		for(var i=0;i<3;i++){
			$(obj.a+i).className='';
		}
		$(obj.a+index).className='currA';
	}
	function displayNOrY(){
		obj.current=index;
		for(var i=0;i<3;i++){
			if(i==index)
				$(obj.ul+'_'+i).style.display='block';
			else
				$(obj.ul+'_'+i).style.display='none';
		}
	}
}
function xlAjax(url, pars, successFun) {
	var doc = document.getElementById('iframe_proxy').contentWindow;
	return doc.pxlAjax(url,pars,successFun);
}
function showRecommend(response) {
	//alert(eval(response.responseText).length) ;
	var RecommendData = eval(response.responseText);
	var ShowStr = "" ;
	for (i=0;i<RecommendData.length;i++) {
		ShowStr += '<li><a href="'+RecommendData[i]['vod_link']+'" class="playpic" title="点击播放&#13;'+RecommendData[i]['title']+'"><img src="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+RecommendData[i]['poster']+'" /><em></em></a><a href="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+RecommendData[i]['vod_link']+'" title="点击播放&#13;'+RecommendData[i]['title']+'">'+RecommendData[i]['title']+'</a></li>' ;
	}
	document.getElementById("kankan_recom").innerHTML = ShowStr ;
}
function __init__() {
	var ajax = xlAjax("http://movie.xunlei.com/kankan_recommend.php?movieid="+id,"",showRecommend);
	ajax.get();
}
function randomOrder (targetArray) {
	var arrayLength = targetArray.length ;
	var tempArray1 = new Array();
	for (var i = 0; i < arrayLength; i ++) {
		tempArray1 [i] = i ;
	}
	var tempArray2 = new Array();
	for (var i = 0; i < arrayLength; i ++) {
		tempArray2 [i] = tempArray1.splice (Math.floor (Math.random () * tempArray1.length) , 1) ;
	}
	var tempArray3 = new Array();
	for (var i = 0; i < arrayLength; i ++) {
		tempArray3 [i] = targetArray [tempArray2 [i]] ;
	}
	return tempArray3 ;
}
function showBigMovie() {
	var BigMovieshow = randomOrder(BigMovie) ;
	var showHTML = "" ;
	for(i=0;i<6;i++) {
		showHTML += '<li><a href="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+BigMovieshow[i]['link']+'" class="playpic" title="点击播放&#13;'+BigMovieshow[i]['title']+' ('+BigMovieshow[i]['year']+')"><img src="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+BigMovieshow[i]['img']+'"/><em></em></a></li>' ;
	}
	document.getElementById("BigMovieCont").innerHTML = showHTML ;
}
function getParameter(name){
    var search = document.location.search;
    var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
    var matcher = pattern.exec(search);
    var items = null;
    if(null != matcher){
        items = decodeURIComponent(matcher[1]);
        //items = unescape(matcher[1]);
    }
    return items;
}


var MiniSite=new Object();
MiniSite.Browser={
    ie:/msie/.test(window.navigator.userAgent.toLowerCase()),
    moz:/gecko/.test(window.navigator.userAgent.toLowerCase()),
    opera:/opera/.test(window.navigator.userAgent.toLowerCase()),
    safari:/safari/.test(window.navigator.userAgent.toLowerCase())
};

MiniSite.JsLoader={
    load:function(sUrl,charset,fCallback){
        var _script=document.createElement('script');
        _script.setAttribute('charset',charset);
        _script.setAttribute('type','text/javascript');
        _script.setAttribute('src',sUrl);
        document.getElementsByTagName('head')[0].appendChild(_script);
        if(MiniSite.Browser.ie){
            _script.onreadystatechange=function(){
                if(this.readyState=='loaded'||this.readyState=='complete'){
                    //fCallback();
					//setTimeout(fCallback, 50);
					setTimeout(function(){try{fCallback();}catch(e){}}, 50);
                }
            };
        }else if(MiniSite.Browser.moz){
            _script.onload=function(){
                //fCallback();
				//setTimeout(fCallback, 50);
				setTimeout(function(){try{fCallback();}catch(e){}}, 50);
            };
        }else{
            //fCallback();
			//setTimeout(fCallback, 50);
			setTimeout(function(){try{fCallback();}catch(e){}}, 50);
        }
    }
};

/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
//this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.skipDetect=true;
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}else{this.addParam("wmode","transparent");}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){
_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+=" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();
return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=15;i>6;i--){
try{
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_25=new deconcept.PlayerVersion([i,0,0]);
break;}
catch(e){}}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}
return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){
var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){
return q.substring(q.indexOf("=",_2d)+1,_2e);
}}return "";}};
if(Array.prototype.push==null){
Array.prototype.push=function(_2f){
this[this.length]=_2f;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for backwards compatibility
var SWFObject=deconcept.SWFObject;

function flv_init() {
	document.getElementById('PlayerCtrl').flv_setPlayeUrl([MediaVideoConfigs.items[0].videoUrl]);
	document.getElementById("PlayerCtrl").flv_setFirstFrame(MediaVideoConfigs.items[0].coverUrl);
}

function prestart(){
	//alert('prestart');
	var time=0;
	var error = 0;
	var printnewswf = false;
	var playerTimer = setInterval(function(){
		if(typeof(document.getElementById('PlayerCtrl')=='object')){
			PLAYCTRL = document.getElementById('PlayerCtrl');
			try{
				flv_init() ;
				clearInterval(playerTimer);
			}catch(e){
				error = error + 1;
				time=time+100;
				if(time>10000){
					clearInterval(playerTimer);
				}
				if(error>3 && !printnewswf){
					printSwf(1);
					printnewswf = true ;
					error=0 ;
				}
			}
		}else{
			time=time+100;
			if(time>20000){
				clearInterval(playerTimer);
			}
		}
	}, 100);
}


function printSwf(random){
	if(random==1){
		var so = new SWFObject("http://images.movie.xunlei.com/www_swf/PlayerCtrl.swf?fullscreenbtn=1&id=0&channel=ad&width=208&height=174&autostart=0&refer=www&"+Math.random(), "PlayerCtrl", "208", "174", "7", "#000000");
	}else{
		var so = new SWFObject("http://images.movie.xunlei.com/www_swf/PlayerCtrl.swf?fullscreenbtn=1&id=0&channel=ad&width=208&height=174&autostart=0&refer=www", "PlayerCtrl", "208", "174", "7", "#000000");
	}
	so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", "true");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write("_player");
	document.getElementById("IndexVideoPlayerOuterCont").style.display = "block" ;
	document.getElementById("BigMovieOuterCont").style.display = "none" ;
}
function showMediaTitle() {
	document.getElementById("MediaTitle").innerHTML = '<a href="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+MediaVideoConfigs.items[0].clickUrl+'" title="'+MediaVideoConfigs.items[0].title+'">'+MediaVideoConfigs.items[0].title+'</a><a href="../迅雷看看——中国最高清的影视视频门户，正版发行平台_files/'+MediaVideoConfigs.items[0].clickUrl+'" title="'+MediaVideoConfigs.items[0].title+'" class="more">查看详细>></a>' ;
}
function checkAndShowSeedsVideo() {
	try{
		if( MediaVideoConfigs.items[0].videoUrl && MediaVideoConfigs.items[0].coverUrl && MediaVideoConfigs.items[0].clickUrl && MediaVideoConfigs.items[0].title) {
			printSwf();prestart();showMediaTitle();
		}
		else {
			
		}
	}
	catch (e) {}
	
}